#ifndef SPACECOL2D_H
#define SPACECOL2D_H
#define ROH 2
#define INTLENGTH 8 // internode length
#define THETA 90
#define R 4
#include "treegen.h"
#include "treegen2d.h"
#include "treerender.h"
#include "renderer.h"
#include "common.h"
#include "artistic.h"
#include "qgl.h"
#include "math.h"
#include "GL/glu.h"

using namespace std;
class Artistic;

class Block // a square holding markers in the canvas
{
public:
    double m_size; // length of the square side
    float3 startCoord;
    int numMarkers; // number of markers
    int row;
    int col;
    // each marker has 4 components: x coord, y coord, z coord, index of the bud it belongs to and distance to the closest bud's end.
    // if distance == -1, this marker has been deleted.
    // distance has to be < R*INTLENGTH
    double * m_markers;
    Block()
    {
        m_size = 0.0;
        numMarkers = 0;
        m_markers = NULL;
    }

    void updateSize(double size, float3 start)
    {
        m_size = size;
        numMarkers = (int) size*size/8.0;
        if (m_markers) delete m_markers;
        m_markers = new double[numMarkers*5];
        startCoord = start;
    }

};

class SpaceCol2D
{
public:
    SpaceCol2D();
    ~SpaceCol2D();
    void generateMarkers();
    //void createRoot(float3 start, float3 end);
    void initialize(float3 start, float3 end, float theta, float diameter);
    void updateTree(TreeGen2D *newTree);
    void drawMarkers();
public:
    Artistic * m_widget;

    TreeGen2D * m_tree;

private:
        int numBlock;
    Block * m_blocks;
    int internodeLength;




};

#endif // SPACECOL2D_H
